home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr51
/
tag_utes.zip
/
REDOTAGS.PRG
< prev
next >
Wrap
Text File
|
1993-04-01
|
5KB
|
130 lines
PROCEDURE RedoTags
*-------------------------------------------------------------------------------
*-- Programmer..: David Love (DAVIDLOVE)
*-- Date........: 01/20/1992
*-- Notes.......: This routine is a "generic" MDX cleanup routine. It is useful
*-- for handling "bloated" MDX files -- ones that have been around
*-- awhile (they tend to be larger than necessary). This routine
*-- store the FOR/ASCENDING/UNIQUE options to a database and the
*-- tag keys in an array, delete the tags, and rebuild the MDX
*-- file from scratch, restoring all tag names and key expressions
*-- The MDX SHOULD be smaller (one test showed one MDX to go
*-- from 67,584 bytes to 59,392 bytes).
*-- : This routine will only act on the database's production mdx
*-- file (ie. has the same name as the dbf file).
*-- : This procedure will create a database file (RedoTags.dbf) and
*-- a text file (RedoTags.txt). Upon completion, both files will
*-- be erased. These files are necessary because dBASE IV 1.1
*-- does not have functions that return the FOR/DESCENDING/UNIQUE
*-- options of the index tags.
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: 01/22/1992 -- Recognizes FOR/UNIQUE/DESCENDING clauses
*-- 01/24/1992 -- Incorporates auto-creation of Tags.dbf
*-- 01/31/1991 -- Minor cleanup, removed three unneeded lines
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: do RedoTags with "<cDBF>"
*-- Example.....: do RedoTags with "Referral"
*-- Returns.....: None
*-- Parameters..: cDBF = Name of DATABASE file, no extension necessary.
*-- Acknowledgement..: Bowen Moursund for the code that creates RedoTags.dbf
*-- (Download PRGCREAT.ZIP for more info.)
*-- : Ken Mayer for interest and encouragement
*-------------------------------------------------------------------------------
parameter cDBF
use (cDBF)
*-- only perform routine if an index tag exists
if "" # tag( (cdbf), 1)
private nTags, nMaxTags, mkey, mtag, cConsole
*-- used to find UNIQUE/DESCENDING/FOR clauses
cConsole = set("CONSOLE")
set console off
if file("RedoTags.txt")
erase "RedoTags.txt"
endif
list stat to file RedoTags.txt
*-- creates a database file, RedoTags.dbf, which has three 254 char fields
if file("RedoTags.dbf")
erase "RedoTags.dbf"
endif
set printer to file RedoTags.dbf
set printer on
??? "{3}{92}{1}{24}{0}{0}{0}{0}{129}{0}{251}{2}{0}{0}{0}{0}{0}{0}{0}{0}{0}"+;
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{201}{0}{84}{65}{71}{83}{49}{0}{0}{0}{0}{0}{0}"+;
"{67}{3}{0}{26}{84}{254}{0}{0}{0}{1}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{84}"+;
"{65}{71}{83}{50}{0}{0}{0}{0}{0}{0}"
??? "{67}{1}{1}{26}{84}{254}{0}{0}{0}{1}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"+;
"{84}{65}{71}{83}{51}{0}{0}{0}{0}{0}{0}{67}{255}{1}{26}{84}{254}{0}{0}{0}"+;
"{1}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{13}{26}"
set printer to
set printer off
use RedoTags
append from RedoTags.txt type sdf for "TAG:" $ tags1
set console &cConsole
*-- figure out how many tags there are
nMaxTags = reccount()
*-- put any 'for' expression in a separate field
replace all tags3 with iif( at("For:",tags1) > 0, ;
substr( tags1, at("For:",tags1) + 5) + " " + trim(tags2),"")
*-- declare an array to hold the info
declare aTags[nMaxTags,5]
*-- store descending/unique/for info to the array variables
go top
nTags = 1
do while .not. eof()
store "(Descending)" $ tags1 to aTags[nTags,3]
store "(Unique)" $ tags1 to aTags[nTags,4]
store trim( tags3 ) to aTags[nTags,5]
nTags = nTags + 1
skip
enddo
*-- store the key expressions and tags to the array
use (cDBF)
nTags = 1
do while "" # tag( (cDBF),nTags )
store key( (cDBF),nTags ) to aTags[nTags,1] && grab the key
store tag( (cDBF),nTags ) to aTags[nTags,2] && grab the tagname
nTags = nTags + 1
enddo
*-- now, delete the tags
do while "" # tag( (cDBF),1 )
delete tag tag( (cDBF),1 )
enddo
*-- rebuild the MDX, tag by tag ...
nTags = 1
do while nTags <= nMaxTags
mkey = aTags[nTags,1] + ;
iif(aTags[nTags,3]," descending","") + ;
iif(aTags[nTags,4]," unique","") + ;
iif(""#trim(aTags[nTags,5])," for "+trim(aTags[nTags,5]),"")
mtag = aTags[nTags,2]
index on &mkey. TAG &mtag.
nTags = nTags + 1
enddo
*-- delete the dbf and text files
erase "RedoTags.dbf"
erase "RedoTags.txt"
*-- release the array ...
release aTags
endif && check for tags ...
use && close database
RETURN
*-- EoP: RedoTags